{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from web3 import Web3\n",
    "from eth_typing import HexStr"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>连接节点</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3 = Web3(Web3.IPCProvider('data/geth.ipc'))\n",
    "w3.isConnected()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>列出当前的账号和余额</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Account:0xb6bEBfBbC7E5EE1Dbf5612f2C298370E94C69db8, Balance:5793.99999999999991 ether\n",
      "Account:0xbDcB2416e02b9e4f7714D6546606af08764852D2, Balance:0 ether\n"
     ]
    }
   ],
   "source": [
    "for account in w3.eth.accounts:\n",
    "    print(\"Account:{}, Balance:{} ether\".format(account, Web3.fromWei(w3.eth.get_balance(account), 'ether')))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>解锁账号</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.eth.default_account=w3.eth.accounts[0]\n",
    "w3.geth.personal.unlockAccount(w3.eth.accounts[0], 'roy2000')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>编译合约</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import solcx\n",
    "from solcx import compile_source\n",
    "\n",
    "def compile_source_file(file_path):\n",
    "    with open(file_path, 'r') as f:\n",
    "        source = f.read()\n",
    "    return compile_source(source)\n",
    " \n",
    "def deploy_contract(w3, contract_interface):\n",
    "    tx_hash = w3.eth.contract(\n",
    "        abi=contract_interface['abi'],\n",
    "        bytecode=contract_interface['bin']).constructor().transact()\n",
    "    return tx_hash"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>编译并部署预言机</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.geth.personal.unlockAccount(w3.eth.accounts[0], 'roy2000')\n",
    "oracle_contract_source_path = 'oracle.sol'\n",
    "compiled_sol = compile_source_file('oracle.sol')\n",
    "oracle_contract_id, oracle_contract_interface = compiled_sol.popitem()\n",
    "transaction_hash = deploy_contract(w3, oracle_contract_interface)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0x857d10b17A7486c2844ddffb6E4b0773E60fd470\n"
     ]
    }
   ],
   "source": [
    "oracle_contract_address = w3.eth.get_transaction_receipt(transaction_hash)['contractAddress']\n",
    "print(oracle_contract_address)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>部署合约</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "ename": "SolcError",
     "evalue": "An error occurred during execution\n> command: `/home/roy/.solcx/solc-v0.8.7 --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,function-debug,function-debug-runtime,generated-sources,generated-sources-runtime,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,storage-layout,userdoc -`\n> return code: `1`\n> stdout:\n\n> stderr:\nError: Expected identifier but got '='\n  --> <stdin>:14:12:\n   |\n14 |     Oracle = 0x857d10b17A7486c2844ddffb6E4b0773E60fd470;\n   |            ^",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mSolcError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-21-a01ae11afff4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mw3\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgeth\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpersonal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munlockAccount\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw3\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meth\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maccounts\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'roy2000'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mcontract_source_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'getpass.sol'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mcompiled_sol\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompile_source_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'getpass.sol'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      4\u001b[0m \u001b[0mcontract_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_interface\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompiled_sol\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpopitem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0mtransaction_hash\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdeploy_contract\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_interface\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<ipython-input-5-7ce10975444d>\u001b[0m in \u001b[0;36mcompile_source_file\u001b[0;34m(file_path)\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfile_path\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'r'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m         \u001b[0msource\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0mcompile_source\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msource\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdeploy_contract\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_interface\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/solcx/main.py\u001b[0m in \u001b[0;36mcompile_source\u001b[0;34m(source, output_values, import_remappings, base_path, allow_paths, output_dir, overwrite, evm_version, revert_strings, metadata_hash, metadata_literal, optimize, optimize_runs, optimize_yul, no_optimize_yul, yul_optimizations, solc_binary, solc_version, allow_empty)\u001b[0m\n\u001b[1;32m    110\u001b[0m         \u001b[0mCompiler\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m.\u001b[0m \u001b[0mThe\u001b[0m \u001b[0msource\u001b[0m \u001b[0mfile\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mgiven\u001b[0m \u001b[0;32mas\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0mstdin\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    111\u001b[0m     \"\"\"\n\u001b[0;32m--> 112\u001b[0;31m     return _compile_combined_json(\n\u001b[0m\u001b[1;32m    113\u001b[0m         \u001b[0msolc_binary\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msolc_binary\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    114\u001b[0m         \u001b[0msolc_version\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msolc_version\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/solcx/main.py\u001b[0m in \u001b[0;36m_compile_combined_json\u001b[0;34m(output_values, solc_binary, solc_version, output_dir, overwrite, allow_empty, **kwargs)\u001b[0m\n\u001b[1;32m    286\u001b[0m             )\n\u001b[1;32m    287\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 288\u001b[0;31m     stdoutdata, stderrdata, command, proc = wrapper.solc_wrapper(\n\u001b[0m\u001b[1;32m    289\u001b[0m         \u001b[0msolc_binary\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msolc_binary\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    290\u001b[0m         \u001b[0mcombined_json\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcombined_json\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/solcx/wrapper.py\u001b[0m in \u001b[0;36msolc_wrapper\u001b[0;34m(solc_binary, stdin, source_files, import_remappings, success_return_code, **kwargs)\u001b[0m\n\u001b[1;32m    156\u001b[0m             )\n\u001b[1;32m    157\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 158\u001b[0;31m         raise SolcError(\n\u001b[0m\u001b[1;32m    159\u001b[0m             \u001b[0mcommand\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcommand\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    160\u001b[0m             \u001b[0mreturn_code\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mproc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreturncode\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mSolcError\u001b[0m: An error occurred during execution\n> command: `/home/roy/.solcx/solc-v0.8.7 --combined-json abi,asm,ast,bin,bin-runtime,compact-format,devdoc,function-debug,function-debug-runtime,generated-sources,generated-sources-runtime,hashes,interface,metadata,opcodes,srcmap,srcmap-runtime,storage-layout,userdoc -`\n> return code: `1`\n> stdout:\n\n> stderr:\nError: Expected identifier but got '='\n  --> <stdin>:14:12:\n   |\n14 |     Oracle = 0x857d10b17A7486c2844ddffb6E4b0773E60fd470;\n   |            ^"
     ]
    }
   ],
   "source": [
    "w3.geth.personal.unlockAccount(w3.eth.accounts[0], 'roy2000')\n",
    "contract_source_path = 'getpass.sol'\n",
    "compiled_sol = compile_source_file('getpass.sol')\n",
    "contract_id, contract_interface = compiled_sol.popitem()\n",
    "transaction_hash = deploy_contract(w3, contract_interface)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0x6A4188012e98d76AF6E54538fd59b98b1Bab1446\n"
     ]
    }
   ],
   "source": [
    "contract_address = w3.eth.get_transaction_receipt(transaction_hash)['contractAddress']\n",
    "print(contract_address)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>挖矿</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.geth.miner.start(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>运行合约</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "contract_instance = w3.eth.contract(address=contract_address, abi=contract_interface['abi'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "HexBytes('0x673d47cf91fa46cd750f482ff7fb437cfcf5b129404fba158a9f540cef9dc0dd')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.geth.personal.unlockAccount(w3.eth.accounts[0], 'roy2000')\n",
    "contract_instance.functions.deposit('abcdefg').transact(transaction={'value':30000, 'gas': 2100000})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AttributeDict({'blockHash': HexBytes('0x897d6c0d2c2a2954546d152342527a1b9f146e9f76eb855bc5f66f9fc86d434b'),\n",
       " 'blockNumber': 2166,\n",
       " 'from': '0xb6bEBfBbC7E5EE1Dbf5612f2C298370E94C69db8',\n",
       " 'gas': 2100000,\n",
       " 'gasPrice': 1000000000,\n",
       " 'hash': HexBytes('0x390d1f58a9c42d7688cae5ccf1df098f9f24c92603473ac73355405808a55f49'),\n",
       " 'input': '0xa26e1186000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000076162636465666700000000000000000000000000000000000000000000000000',\n",
       " 'nonce': 9,\n",
       " 'to': '0x074467E2C8Be6FC28CEbb1c283240A0C898145eE',\n",
       " 'transactionIndex': 0,\n",
       " 'value': 30000,\n",
       " 'type': '0x0',\n",
       " 'v': 66,\n",
       " 'r': HexBytes('0x7cedb83d5f061c0bbf6b3b7b7586ac056892b7d236551299dbb65844ae16ad19'),\n",
       " 's': HexBytes('0x417b1065c67304c5aad0dc2b6fd807ee485f34a200f2fefb74a526ac3928bbcd')})"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.eth.get_transaction('0x390d1f58a9c42d7688cae5ccf1df098f9f24c92603473ac73355405808a55f49')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "event_filter = w3.eth.filter({\"address\": contract_address})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "event_filter.get_all_entries()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "HexBytes('0x3e679d5bbfec4c7ead1ee19eb06a0050e1c4506d66cbe77e6c17a6bc79279b2f')"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Web3.keccak(text='LogEncryptedData(string,address)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-158-63456d1b0379>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mevents\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "events[0]['data']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'000000000000000000000000b6bebfbbc7e5ee1dbf5612f2c298370e94c69db8'"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "events[0]['data'][-192:-128]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0000000000000000000000000000000000000000000000000000000000000040'"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "events[0]['data'][-256:-192]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b6bebfbbc7e5ee1dbf5612f2c298370e94c69db800000000000000000000000000000000000000000000000000000000000000036162630000000000000000000000000000000000000000000000000000000000'"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_hex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [],
   "source": [
    "oracle_contract_instance = w3.eth.contract(address=oracle_contract_address, abi=oracle_contract_interface['abi'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#event_filter = oracle_contract_instance.events.LogRequest.createFilter(fromBlock=\"latest\")\n",
    "event_filter.get_new_entries()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "block_filter = w3.eth.filter('latest')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[HexBytes('0x1dc3a1e6ed512712db431a1327461cce3f062c884b43cef9f1c2fcb7d2589d57')]"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "block_filter.get_new_entries()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "HexBytes('0xecd291c06e37e514540fa209886a4f711b83f1b61248b718b2c739f9eaf7b966')"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Web3.keccak(text='Logpublickey(string)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "tx_hash = w3.eth.send_transaction({'to':contract_address, 'value':30000, 'data':'0x19ff1d21', 'gas': 2100000})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0x6CA25fbE7e2dCD116a81425b8FDCC4a5DC6c00D5'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "contract_address"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'d'"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chr(0x64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "attribute = w3.eth.get_transaction_receipt('0x8853abded143de6e17a43cc7e8f5c7ecda04e45ab26d3d4eb408d85c23b58d97')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "706"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(attribute['logs'][0]['data'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'000000000000000000000000000000000000000000000000000000000000010f'"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "attribute['logs'][0]['data'][66:130]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [],
   "source": [
    "public_key = '-----BEGIN PUBLIC KEY-----\\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQnknLheeULwy60jUnX8mAOa1q\\nHtXlbFoeqB+BABOfRobKyNVv1oOyw3STLSyiGi40VipRd2sMaz3JJbUiaV0ba3H5\\nwfUkDjINz0+REq2qjSWvU4YALJv4BIA9mgSEbaePwGuM4zZrF3kWTyD6dTswInxn\\nU5AfjrqBMbzciFQTUQIDAQAB\\n-----END PUBLIC KEY-----'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010f2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d4947664d413047435371475349623344514542415155414134474e4144434269514b42675144516e6b6e4c686565554c777936306a556e58386d414f6131710a4874586c62466f6571422b4241424f66526f624b794e5676316f4f79773353544c53796947693430566970526432734d617a334a4a62556961563062613348350a7766556b446a494e7a302b52457132716a535776553459414c4a7634424941396d675345626165507747754d347a5a7246336b575479443664547377496e786e0a553541666a7271424d627a636946515455514944415141420a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d0000000000000000000000000000000000'"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "attribute['logs'][0]['data']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AttributeDict({'blockHash': HexBytes('0x0d6e252d95dc94675f69b603aea270a22ae769cc2e120dbb27ea7e9b5ffa8a3a'),\n",
       " 'blockNumber': 1217,\n",
       " 'contractAddress': None,\n",
       " 'cumulativeGasUsed': 24490,\n",
       " 'effectiveGasPrice': 1000000000,\n",
       " 'from': '0xb6bEBfBbC7E5EE1Dbf5612f2C298370E94C69db8',\n",
       " 'gasUsed': 24490,\n",
       " 'logs': [AttributeDict({'address': '0x074467E2C8Be6FC28CEbb1c283240A0C898145eE',\n",
       "   'topics': [HexBytes('0xecd291c06e37e514540fa209886a4f711b83f1b61248b718b2c739f9eaf7b966')],\n",
       "   'data': '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056464646464000000000000000000000000000000000000000000000000000000',\n",
       "   'blockNumber': 1217,\n",
       "   'transactionHash': HexBytes('0x1ceab6fed6f2a5ce1af6dec4adbf3a48582b9dde8dbc53dda3c5395f5fd16e77'),\n",
       "   'transactionIndex': 0,\n",
       "   'blockHash': HexBytes('0x0d6e252d95dc94675f69b603aea270a22ae769cc2e120dbb27ea7e9b5ffa8a3a'),\n",
       "   'logIndex': 0,\n",
       "   'removed': False})],\n",
       " 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'),\n",
       " 'status': 1,\n",
       " 'to': '0x074467E2C8Be6FC28CEbb1c283240A0C898145eE',\n",
       " 'transactionHash': HexBytes('0x1ceab6fed6f2a5ce1af6dec4adbf3a48582b9dde8dbc53dda3c5395f5fd16e77'),\n",
       " 'transactionIndex': 0,\n",
       " 'type': '0x0'})"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "attribute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.geth.miner.stop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "HexBytes('0xa26e11860cdb80ecca46e4f433c3c9533f6d37cdf0f6eb16343556cfdbcf47ec')"
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Web3.keccak(text='deposit(string)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AttributeDict({'blockHash': HexBytes('0x0d6e252d95dc94675f69b603aea270a22ae769cc2e120dbb27ea7e9b5ffa8a3a'),\n",
       " 'blockNumber': 1217,\n",
       " 'from': '0xb6bEBfBbC7E5EE1Dbf5612f2C298370E94C69db8',\n",
       " 'gas': 2100000,\n",
       " 'gasPrice': 1000000000,\n",
       " 'hash': HexBytes('0x1ceab6fed6f2a5ce1af6dec4adbf3a48582b9dde8dbc53dda3c5395f5fd16e77'),\n",
       " 'input': '0xa26e1186000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056464646464000000000000000000000000000000000000000000000000000000',\n",
       " 'nonce': 15,\n",
       " 'to': '0x074467E2C8Be6FC28CEbb1c283240A0C898145eE',\n",
       " 'transactionIndex': 0,\n",
       " 'value': 30000,\n",
       " 'type': '0x0',\n",
       " 'v': 65,\n",
       " 'r': HexBytes('0x60ec5a0feca832c24976a1da4cc78658670ed07c0db56d64cfa998e2aec3323e'),\n",
       " 's': HexBytes('0x0159d7c552b4a9d2973fd06fa4b8aefae8580dfbf408cbd8413167da5a2eebd1')})"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.eth.get_transaction('0x1ceab6fed6f2a5ce1af6dec4adbf3a48582b9dde8dbc53dda3c5395f5fd16e77')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import time\n",
    "import pprint\n",
    "\n",
    "from web3.providers.eth_tester import EthereumTesterProvider\n",
    "from web3 import Web3\n",
    "from eth_tester import PyEVMBackend\n",
    "from solcx import compile_source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def compile_source_file(file_path):\n",
    "    with open(file_path, 'r') as f:\n",
    "        source = f.read()\n",
    "\n",
    "    return compile_source(source)\n",
    "\n",
    "\n",
    "def deploy_contract(w3, contract_interface):\n",
    "    tx_hash = w3.eth.contract(\n",
    "        abi=contract_interface['abi'],\n",
    "        bytecode=contract_interface['bin']).constructor().transact()\n",
    "\n",
    "    address = w3.eth.get_transaction_receipt(tx_hash)['contractAddress']\n",
    "    return address"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "contract_source_path = 'storage.sol'\n",
    "compiled_sol = compile_source_file('storage.sol')\n",
    "\n",
    "contract_id, contract_interface = compiled_sol.popitem()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Version('0.8.7')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import solcx\n",
    "solcx.install_solc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "ename": "TransactionNotFound",
     "evalue": "Transaction with hash: '0x2771fce2d618f148c5acb8ed07cae198dca09bde77fbb31bbe56edefe5c9dcc6' not found.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTransactionNotFound\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-34-41876f312a66>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0maddress\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdeploy_contract\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_interface\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf'Deployed {contract_id} to: {address}\\n'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<ipython-input-9-8c0f158498e8>\u001b[0m in \u001b[0;36mdeploy_contract\u001b[0;34m(w3, contract_interface)\u001b[0m\n\u001b[1;32m     11\u001b[0m         bytecode=contract_interface['bin']).constructor().transact()\n\u001b[1;32m     12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m     \u001b[0maddress\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mw3\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meth\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_transaction_receipt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtx_hash\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'contractAddress'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     14\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0maddress\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/web3/module.py\u001b[0m in \u001b[0;36mcaller\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m     55\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mLogFilter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meth_module\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmodule\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilter_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0merr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfilter_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m         \u001b[0mresult_formatters\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merror_formatters\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnull_result_formatters\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mresponse_formatters\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 57\u001b[0;31m         result = w3.manager.request_blocking(method_str,\n\u001b[0m\u001b[1;32m     58\u001b[0m                                              \u001b[0mparams\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     59\u001b[0m                                              \u001b[0merror_formatters\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/web3/manager.py\u001b[0m in \u001b[0;36mrequest_blocking\u001b[0;34m(self, method, params, error_formatters, null_result_formatters)\u001b[0m\n\u001b[1;32m    185\u001b[0m         \"\"\"\n\u001b[1;32m    186\u001b[0m         \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_make_request\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 187\u001b[0;31m         return self.formatted_response(response,\n\u001b[0m\u001b[1;32m    188\u001b[0m                                        \u001b[0mparams\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    189\u001b[0m                                        \u001b[0merror_formatters\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/web3/manager.py\u001b[0m in \u001b[0;36mformatted_response\u001b[0;34m(self, response, params, error_formatters, null_result_formatters)\u001b[0m\n\u001b[1;32m    170\u001b[0m             \u001b[0;31m# null_result_formatters raise either a BlockNotFound\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    171\u001b[0m             \u001b[0;31m# or a TransactionNotFound error, depending on the method called\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 172\u001b[0;31m             \u001b[0mapply_null_result_formatters\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnull_result_formatters\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    173\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    174\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'result'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/web3/manager.py\u001b[0m in \u001b[0;36mapply_null_result_formatters\u001b[0;34m(null_result_formatters, response, params)\u001b[0m\n\u001b[1;32m     77\u001b[0m ) -> RPCResponse:\n\u001b[1;32m     78\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0mnull_result_formatters\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 79\u001b[0;31m         \u001b[0mformatted_resp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpipe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnull_result_formatters\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     80\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mformatted_resp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     81\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/cytoolz/functoolz.pyx\u001b[0m in \u001b[0;36mcytoolz.functoolz.pipe\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/cytoolz/functoolz.pyx\u001b[0m in \u001b[0;36mcytoolz.functoolz.c_pipe\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/web3/_utils/method_formatters.py\u001b[0m in \u001b[0;36mraise_transaction_not_found\u001b[0;34m(params)\u001b[0m\n\u001b[1;32m    644\u001b[0m         \u001b[0mmessage\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Unknown transaction hash\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    645\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 646\u001b[0;31m     \u001b[0;32mraise\u001b[0m \u001b[0mTransactionNotFound\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    647\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    648\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mTransactionNotFound\u001b[0m: Transaction with hash: '0x2771fce2d618f148c5acb8ed07cae198dca09bde77fbb31bbe56edefe5c9dcc6' not found."
     ]
    }
   ],
   "source": [
    "address = deploy_contract(w3, contract_interface)\n",
    "print(f'Deployed {contract_id} to: {address}\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['0xb6bEBfBbC7E5EE1Dbf5612f2C298370E94C69db8',\n",
       " '0xbDcB2416e02b9e4f7714D6546606af08764852D2']"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.geth.personal.list_accounts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.geth.personal.unlockAccount(w3.geth.personal.list_accounts()[1], 'roy2000')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.eth.defaultAccount = w3.geth.personal.list_accounts()[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2384000000000000000000"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.eth.get_balance(w3.geth.personal.list_accounts()[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.geth.miner.start(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AttributeDict({'blockHash': HexBytes('0x633ae07e83880d082747f6140780a395e3b3ecc35bd0bf8ee61704526a825a4c'),\n",
       " 'blockNumber': 1193,\n",
       " 'contractAddress': '0xE9AB90b6735c9874027DFe6d55B595512dC40cf3',\n",
       " 'cumulativeGasUsed': 142525,\n",
       " 'effectiveGasPrice': 1000000000,\n",
       " 'from': '0xbDcB2416e02b9e4f7714D6546606af08764852D2',\n",
       " 'gasUsed': 142525,\n",
       " 'logs': [],\n",
       " 'logsBloom': HexBytes('0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'),\n",
       " 'status': 1,\n",
       " 'to': None,\n",
       " 'transactionHash': HexBytes('0x2771fce2d618f148c5acb8ed07cae198dca09bde77fbb31bbe56edefe5c9dcc6'),\n",
       " 'transactionIndex': 0,\n",
       " 'type': '0x0'})"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w3.eth.get_transaction_receipt('0x2771fce2d618f148c5acb8ed07cae198dca09bde77fbb31bbe56edefe5c9dcc6')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "w3.geth.miner.stop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
